//
//  SnowView.m
//  DrawRect
//
//  Created by cocoazxj@163.com on 15/4/19.
//  Copyright (c) 2015年 handcool. All rights reserved.
//

#import "SnowView.h"

@interface SnowView()
@property (nonatomic, strong) UIImage *image;
@property (nonatomic, assign) CGFloat change;
@end
@implementation SnowView
- (void)awakeFromNib
{
    self.change = 20.0;
    CADisplayLink *link = [CADisplayLink displayLinkWithTarget:self selector:@selector(fresh)];
    [link addToRunLoop:[NSRunLoop mainRunLoop] forMode:NSDefaultRunLoopMode];
}

- (void)drawRect:(CGRect)rect {
    // Drawing code
    if(self.frame.size.height == self.change ++) {
        self.change = 20;
    }
    UIImage *img = [UIImage imageNamed:@"snow"];
    [img drawAtPoint:CGPointMake(20, self.change)];
}

- (void)fresh
{
    [self setNeedsDisplay];
}
@end
